package org.galaxyworld.flycode.utils;

import org.apache.commons.lang3.StringUtils;
import org.beetl.core.Context;
import org.beetl.core.VirtualClassAttribute;
import org.galaxyworld.flycode.config.AppConfig;
import org.galaxyworld.flycode.model.Field;

import javax.annotation.Resource;

public class FieldVirtualAttribute implements VirtualClassAttribute {

    @Override
    public Object eval(Object o, String attributeName, Context context) {
        Field field = (Field) o;
        if (attributeName.equals("setterName")) {
            return "set" + StringUtils.capitalize(field.getCodeName());
        } else if (attributeName.equals("getterName")) {
            return "get" + StringUtils.capitalize(field.getCodeName());
        }
        return "";
    }

}
